const rewire = require('rewire')
const {sleep, ramdomRange} = rewire('../common/utils.cjs')
const {wrapFnState, getProgress} = rewire('../common/fnstate.cjs')


async function test(){
  const iterFn = async (x) => { 
    console.log(x)
    if (x % 2 == 0) {
      throw new Error('x偶数')
    }
    await sleep(parseInt(ramdomRange(3000, 5000)))
  }

  const fnState = wrapFnState("test2", 2, iterFn, console.log)

  await fnState([1,2,3,4,5,6,7,8,9,0])
}


async function test2(){
  const rs = await getProgress("xiachufang")
  console.log(rs)
}

test2()